<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>商品设置</title>
    <link href="https://cdn.bootcss.com/twitter-bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/admin/css/style.css"/>
    <link rel="stylesheet" href="__STATIC__/admin/assets/css/ace.min.css"/>
    <link rel="stylesheet" href="__STATIC__/admin/assets/css/font-awesome.min.css"/>

    <link href="__STATIC__/admin/Widget/icheck/icheck.css" rel="stylesheet" type="text/css"/>
    <!--[if IE 7]>
    <link rel="stylesheet" href="__STATIC__/admin/assets/css/font-awesome-ie7.min.css"/>
    <![endif]-->
    <!--[if lte IE 8]>
    <link rel="stylesheet" href="__STATIC__/admin/assets/css/ace-ie.min.css"/>

    <![endif]-->
    <script src="__STATIC__/admin/js/jquery-1.9.1.min.js"></script>
    <script src="__STATIC__/admin/assets/js/bootstrap.min.js"></script>
    <script src="__STATIC__/admin/Widget/My97datePicker/WdatePicker.js"></script>
    <!--图片上传相关插件-->
    <link rel="stylesheet" href="__STATIC__/admin/bootstrap-fileinput-master/css/fileinput.css"/>
    <script src="__STATIC__/admin/bootstrap-fileinput-master/js/fileinput.js"></script>
    <script src="__STATIC__/admin/bootstrap-fileinput-master/js/locales/zh.js"></script>
    <style>
        select{
            margin-left: 10px;
            width: 100px;
        }
        textarea{
            width: 600px !important;
            height: 300px !important;
        }

    </style>
</head>

<body>
<div class="type_style container-fluid">
    <div class="crumbs">
        <ul>
            <li>
                <a href="index.html">商品管理</a>
            </li>
            <li class="uline">/</li>
            <li>
                <a class="active" href="javascript:;">设置商品</a>
            </li>

        </ul>
    </div>
    <form class="form-horizontal" id="form1" action="{:url('product/set')}" method="post">
        <div style="text-align: center;">
            <input type="submit" value="提交" class="btn btn-primary">
        </div>
        <!--标签页-->
        <ul class="nav nav-tabs" role="tablist">
            <li role="presentation" class="active"><a href="#basic" aria-controls="home" role="tab" data-toggle="tab">基本信息</a></li>
            <li role="presentation"><a href="#specifications" aria-controls="profile" role="tab" data-toggle="tab">规格信息</a></li>
            <li role="presentation"><a href="#seo" aria-controls="messages" role="tab" data-toggle="tab">SEO信息</a></li>
            <li role="presentation"><a href="#des" aria-controls="settings" role="tab" data-toggle="tab">描述信息</a></li>
            <li role="presentation"><a href="#img" aria-controls="settings" role="tab" data-toggle="tab">图片信息</a></li>
        </ul>
        <div class="tab-content">
            <!--商品基本信息-->
            <div role="tabpanel" class="tab-pane active" id="basic">
                <div class="form-group">
                    <label for="title" class="col-sm-2 control-label">名称</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="title" name="title" required
                        value="{$product.title|default=''}">
                    </div>
                </div>
                <div class="form-group">
                    <label for="upc" class="col-sm-2 control-label">upc</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="upc" name="upc"
                        value="{$product.upc|default=''}">
                    </div>
                </div>
                <div class="form-group">
                    <label for="quantity" class="col-sm-2 control-label">库存</label>
                    <div class="col-sm-6">
                        <input type="number" class="form-control" id="quantity" name="quantity"
                        value="{$product.quantity|default=''}">
                    </div>

                </div>
                <div class="form-group">
                    <label for="sku_id" class="col-sm-2 control-label">单位</label>
                    <div class="col-sm-6">
                        <select name="sku_id" id="sku_id">
                            {foreach $sku_list as $item}
                            <option value="{$item.id}"{if condition="$product.sku_id==$item['id']"}selected{/if}>{$item.title}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="stock_status_id" class="col-sm-2 control-label">库存状态</label>
                    <div class="col-sm-6">
                        <select name="stock_status_id" id="stock_status_id">
                            {foreach $stock_list as $item}
                            <option value="{$item.id}"
                            {if condition="$product.stock_status_id==$item.id"}selected{/if}>{$item.title}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="minimum" class="col-sm-2 control-label">最少起售</label>
                    <div class="col-sm-6">
                        <input type="number" class="form-control" id="minimum" name="minimum"
                         value="{$product.minimum|default=0}">
                    </div>
                </div>
                <div class="form-group">
                    <label for="price" class="col-sm-2 control-label">价格</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="price" name="price"
                         value="{$product.price|default=''}">
                    </div>
                </div>
                <div class="form-group">
                    <label for="price_origin" class="col-sm-2 control-label">原价</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="price_origin" name="price_origin"
                        value="{$product.price_origin|default=''}">
                    </div>
                </div>
                <div class="form-group">
                    <label for="date_available" class="col-sm-2 control-label">起售时间</label>
                    <div class="col-sm-6">
                        <input type="text" onclick="WdatePicker()" class="form-control" id="date_available"
                               name="date_available" value="{$product.date_available|default=''}">
                    </div>
                </div>
                <div class="form-group">
                    <label for="sort" class="col-sm-2 control-label">排序</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="sort" name="sort"
                        value="{$product.sort|default=''}">
                    </div>
                </div>

                <div class="form-group">
                    <label for="meta_description" class="col-sm-2 control-label">是否扣减库存</label>
                    <div class="col-sm-6">
                        <div class="radio">
                            <label>
                                <input type="radio" name="is_subtract" value=""
                                       {if condition="$product.is_subtract==1"}checked{/if}>
                                扣减
                            </label>
                        </div>
                        <div class="radio">
                            <label>
                                <input type="radio" name="is_subtract" value=""
                                {if condition="$product.is_subtract==0"}checked{/if}>
                                不扣减
                            </label>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="meta_description" class="col-sm-2 control-label">是否支持配送</label>
                    <div class="col-sm-6">
                        <div class="radio">
                            <label>
                                <input type="radio" name="is_shipping" id="optionsRadios1" value="option1"
                                       {if condition="$product.is_shipping==1"}checked{/if}>
                                支持
                            </label>
                        </div>
                        <div class="radio">
                            <label>
                                <input type="radio" name="is_shipping" id="optionsRadios2" value="option2"
                                {if condition="$product.is_shipping==0"}checked{/if}>
                                不支持
                            </label>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="meta_description" class="col-sm-2 control-label">是否上架</label>
                    <div class="col-sm-6">
                        <div class="radio">
                            <label>
                                <input type="radio" name="is_sale" value="option1"
                                       {if condition="$product.is_sale==1"}checked{/if}>
                                支持
                            </label>
                        </div>
                        <div class="radio">
                            <label>
                                <input type="radio" name="is_sale" value="option2"
                                {if condition="$product.is_sale==0"}checked{/if}>
                                不支持
                            </label>
                        </div>
                    </div>
                </div>
            </div>
            <!--规格信息-->
            <div role="tabpanel" class="tab-pane" id="specifications">
                <div class="form-group">
                    <label for="length" class="col-sm-2 control-label">长</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="length" name="length"
                        value="{$product.length|default=0}">
                    </div>
                </div>
                <div class="form-group">
                    <label for="width" class="col-sm-2 control-label">宽</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="width" name="width"
                        value="{$product.width|default=0}">
                    </div>
                </div>
                <div class="form-group">
                    <label for="height" class="col-sm-2 control-label">高</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="height" name="height"
                        value="{$product.height|default=0}">
                    </div>
                </div>
                <div class="form-group">
                    <label for="length_unit_id" class="col-sm-2 control-label">长度单位</label>
                    <div class="col-sm-6">
                        <select name="length_unit_id" id="length_unit_id">
                            {foreach $length_list as $item}
                            <option value="{$item.id}" {if condition="$product.length_unit_id==$item.id"}selected{/if}>{$item.title}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="weight" class="col-sm-2 control-label">重量</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="weight" name="weight"
                        value="{$product.weight}">
                    </div>
                </div>
                <div class="form-group">
                    <label for="weight_unit_id" class="col-sm-2 control-label">重量单位</label>
                    <div class="col-sm-6">
                        <select name="weight_unit_id" id="weight_unit_id">
                            {foreach $weight_list as $item}
                            <option value="{$item.id}"
                            {if condition="$product.weight_unit_id==$item.id"}selected{/if}>{$item.title}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="brand_id" class="col-sm-2 control-label">品牌</label>
                    <div class="col-sm-6">
                        <select name="brand_id" id="brand_id">
                            {foreach $brand_list as $item}
                            <option value="{$item.id}"
                            {if condition="$product.brand_id==$item.id"}selected{/if}>{$item.title}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="category_id" class="col-sm-2 control-label">类别</label>
                    <div class="col-sm-6">
                        <select name="category_id" id="category_id">
                            {foreach $category_list as $item}
                            <option value="{$item.id}" {if condition="$product.category_id==$item.id"}selected{/if}>{$item.title}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
            </div>
            <!--SEO-->
            <div role="tabpanel" class="tab-pane" id="seo">
                <div class="form-group">
                    <label for="meta_title" class="col-sm-2 control-label">SEO标题</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="meta_title" name="meta_title"
                        value="{$product.meta_title|default=''}">
                    </div>
                </div>
                <div class="form-group">
                    <label for="meta_keywords" class="col-sm-2 control-label">SEO关键字</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="meta_keywords" name="meta_keywords"
                        value="{$product.meta_keywords|default=''}">
                    </div>
                </div>
                <div class="form-group">
                    <label for="meta_description" class="col-sm-2 control-label">SEO描述</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" id="meta_description" name="meta_description"
                        value="{$product.meta_description|default=''}">
                    </div>
                </div>
            </div>
            <!--描述信息-->
            <div role="tabpanel" class="tab-pane" id="des">
                <div>
                    <label for="meta_description" class="col-sm-2 control-label">描述</label>
                    <div class="col-sm-6">
                        <textarea class="form-control" name="description">{$product.description|default=''}</textarea>
                    </div>
                </div>
            </div>

            <div role="tabpanel" class="tab-pane" id="img">
                {if condition="!empty($product.image_thumb)"}
                <img src="{$product.image_thumb}" alt="" id="img1">
                {/if}
                <input id="imgUpload" type="file" class="file-loading">
                <input type="hidden" name="image" id="image" value="{$product.image|default=''}">
                <input type="hidden" name="image_thumb" id="image_thumb" value="{$product.image_thumb|default=''}">
            </div>
        </div>
    </form>
</div>

<script type="text/javascript" src="__STATIC__/admin/Widget/Validform/5.3.2/Validform.min.js"></script>
</body>
</html>
<script>
    $('#imgUpload').fileinput({
        language: 'zh',
        uploadUrl: '{:url("product/uploadImg")}',
        autoReplace: true,
        maxFileCount: 10,
        allowedFileExtensions: ["jpg", "png", "gif"],
        dropZoneEnabled:false,//不显示拖拽区域
        showCaption:false,
        browseClass: "btn btn-primary", //按钮样式
        previewFileIcon: "<i class='glyphicon glyphicon-king'></i>"
    });
    //检测上传成功
    $('#imgUpload').on('fileuploaded', function (e, data) {
        if (data.response.status > 0) {
            $('#image').val(data.response.path);
            $('#image_thumb').val(data.response.thumb);
            $('#img1').remove();
        } else {
            alert(data.response.err);
        }
    })

</script>